package LeetCode;

import java.util.HashSet;
import java.util.Set;

public class LC_217_ContainsDuplicate {

    public static void main(String[] args) {

    }

    static class Solution {
        public boolean containsDuplicate(int[] nums) {
            Set<Integer> unique = new HashSet<>();
            for (int x : nums) {
                if (unique.contains(x)) return true;
                else unique.add(x);
            }
            return false;
        }
    }

    static class Solution_2 {
        public boolean containsDuplicate(int[] nums) {
            Set<Integer> unique = new HashSet<>();
            for (int x : nums) {
                unique.add(x);
            }
            return !(unique.size() == nums.length);
        }
    }

}